

#ifndef PORTMACRO_H
#define PORTMACRO_H


//RVCT warning for volatile
#pragma diag_suppress 191


/*-----------------------------------------------------------
 * Port specific definitions.
 *
 * The settings in this file configure FreeRTOS correctly for the
 * given hardware and compiler.
 *
 * These settings should not be altered.
 *-----------------------------------------------------------
 */

/* Type definitions. */
#define portCHAR        char
#define portFLOAT       float
#define portDOUBLE      double
#define portLONG        long
#define portSHORT       short
#define portSTACK_TYPE  unsigned portLONG
#define portBASE_TYPE   portLONG


#if( configUSE_16_BIT_TICKS == 1 )
   typedef unsigned portSHORT portTickType;
   #define portMAX_DELAY ( portTickType ) 0xffff
#else
   typedef unsigned portLONG portTickType;
   #define portMAX_DELAY ( portTickType ) 0xffffffff
#endif

/*-----------------------------------------------------------*/

/* Hardware specifics. */
#define portSTACK_GROWTH         ( -1 )
#define portTICK_RATE_MS         ( ( portTickType ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT       4
#define portYIELD()					__asm volatile ( "SWI 0" )
#define portNOP()					__asm volatile ( "NOP" )
/*-----------------------------------------------------------*/

/* Critical section handling. */
void vPortEnterCritical( void );
void vPortExitCritical( void );

#define portENTER_CRITICAL()     vPortEnterCritical()
#define portEXIT_CRITICAL()      vPortExitCritical()

	#define portDISABLE_INTERRUPTS()											\
		asm volatile (															\
			"STMDB	SP!, {R0}		\n\t"	/* Push R0.						*/	\
			"MRS	R0, CPSR		\n\t"	/* Get CPSR.					*/	\
			"ORR	R0, R0, #0x80	\n\t"	/* Disable IRQ      			*/	\
			"MSR	CPSR, R0		\n\t"	/* Write back modified value.	*/	\
			"LDMIA	SP!, {R0}			" )	/* Pop R0.						*/
			
	#define portENABLE_INTERRUPTS()												\
		asm volatile (															\
			"STMDB	SP!, {R0}		\n\t"	/* Push R0.						*/	\
			"MRS	R0, CPSR		\n\t"	/* Get CPSR.					*/	\
			"BIC	R0, R0, #0x80	\n\t"	/* Enable IRQ   				*/	\
			"MSR	CPSR, R0		\n\t"	/* Write back modified value.	*/	\
			"LDMIA	SP!, {R0}			" )	/* Pop R0.						*/


/*-----------------------------------------------------------*/

/* Task utilities. */
#define portEND_SWITCHING_ISR( xSwitchRequired )   \
{                                      \
extern void vTaskSwitchContext( void );            \
                                       \
   if( xSwitchRequired )                     \
   {                                   \
      vTaskSwitchContext();                  \
   }                                   \
}
/*-----------------------------------------------------------*/   

/* Compiler specifics */
#define inline

/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )

#endif /* PORTMACRO_H */


